# This file contains the main loop of the game.
# It pulls in the data files, and calls the necessary functions to run the game.

#<<<<< IMPORT DATA FILES >>>>>

from game_functions import *
from board          import board_data
from skills         import skill_data
from events         import event_data
from quorum         import quorum_data
from loyalty        import loyalty
from destination    import destinations
from game           import *
from characters     import characters

# <<<< INITIALIZE GAME >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
(events,
 skills,
 players,
 current_player,
 admiral,
 president,
 loyalty,
 quorum,
 board_data['ship_locations']) = init_game(event_data,
                                           skill_data,
                                           quorum_data,
                                           characters,
                                           loyalty,
                                           board_data['ship_locations'])

raw_input('The game is about to begin, press any key to continue!')

# <<<< MAIN LOOP >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

while game_end==False:
    
    # DISPLAY:  Board State/Character State -
    display('board',None,{'board':board_data,'players':players})

    #________________________________________
    # PLAYER ACTION PHASE
    # * Current Player prompted to take move / action
    # * Location Options Displayed (Move Action)
    # * Location Action Displayed
    # * Card Actions Displayed
    # * Player Actions Displayed
    # * Process player Move / Action
    print '\n'
    print players[current_player]['name'],'/',players[current_player]['character'],',  Please choose from the following actions:'
    print 'Current Location:  ', players[current_player]['location']
    print '(M)ove, (A)ction, View (L)ocation, View (C)haracter, View Loyalt(Y), View (B)oard'
    

    #________________________________________
    # EVENT CARD PHASE
    # * After player actions / moves, get new event card:
    current_event = events['deck'].pop()

    for i in event_data[current_event]['display']:
        None
    #    print i, ':  ', event_data[current_event]['display'][i]

    # * Resolve Event

    # * After event is resolved, move to discard pile:
    events['discard'].append(current_event)

    game_end = True
